/**
 *
 */
package com.naiterui.ehp.bs.doctor.dao.impl;

import cn.hutool.core.collection.CollectionUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.naiterui.ehp.bp.domain.DrMessageConsultOrder;
import com.naiterui.ehp.bs.doctor.dao.IDrMessageConsultOrderDao;
import com.naiterui.ehp.bs.doctor.repository.IDrMessageConsultOrderRepository;

/**
 * 医生图文咨询订单持久层
 *
 * @author xuchong
 * @since 2.7.0
 */
@Component
public class AdDrMessageConsultOrderDaoImpl implements IDrMessageConsultOrderDao {

    @Autowired
    private IDrMessageConsultOrderRepository drMessageConsultOrderRepository;

    @Override
    public void updateMessageConsultOrderSessionStatusBySessionId(String sessionId, Integer sessionStatus) {
        this.drMessageConsultOrderRepository.updateMessageConsultOrderSessionStatusBySessionId(sessionStatus, new Date(), sessionId);
    }

    /**
     * sessionId ，支付状态，批量查询图文咨询订单
     *
     *
     * @return
     */
    @Override
    public List<DrMessageConsultOrder> findByCondition(Set<String> sessionIds) {
        if (CollectionUtil.isEmpty(sessionIds)) {
            return new ArrayList<>();
        }
        //支付成功 + 退款
        List<Integer> statusSet = Arrays.asList(2, 6);
        return this.drMessageConsultOrderRepository.findBySessionIdInAndPayStatusIn(sessionIds, statusSet);
    }

}
